/**
 * @File Name: parser.h
 * @brief  
 * @Author : LiWanglin email:lwl510ll@163.com
 * @Version : 1.0
 * @Creat Date : 2023-07-11
 * 
 * @copyright Copyright (c) 2023 LiWanglin
 */

#ifndef PROTOCOL_PARSER_H
#define PROTOCOL_PARSER_H

#ifdef __cplusplus
extern "C"
{
#endif

#include "protocol_com.h"
#include "queue.h"

typedef struct _parser_st
{
    queue *q;
    cm_uint8 buf[500];
    cm_uint16 buf_len;
} parser_st;

parser_st *parser_init(cm_uint16 buf_len, err_code *err);
parser_st *parser_uninit(parser_st *parser);
cm_int16 parser_add_data(parser_st *parser, const cm_uint8 *data, cm_uint16 len);
protocol_data *parser_deal_data(parser_st *parser, cm_int16 *groups, err_code *err);
err_code parser_clean_data(parser_st *parser);

#ifdef __cplusplus
}
#endif

#endif